package com.example.democrud.employee.pojo;

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.ToStringSerializer;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.example.democrud.enums.SexEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

/**
 * @ClassName Employe
 * @Author Administrator
 * @Date 2020/4/21   8:55
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel("员工实体")
@TableName(value = "employee")
public class EmployeeDO extends Model<EmployeeDO> {

    private static final long serialVersionUID = 1L;


    @JSONField(serializeUsing = ToStringSerializer.class)//log转换成string精度丢失问题
    @ApiModelProperty(value = "员工id" ,notes = "mybatis-plus自动生成")
    @TableId(value = "employee_id",type = IdType.ASSIGN_ID)
    private Long employeeId;

    @ApiModelProperty(value = "姓名")
    @TableField(value = "name",condition = SqlCondition.LIKE)
    private String name;

    @ApiModelProperty(value = "性别")
    @TableField(value = "sex")
    private SexEnum sex;

    @ApiModelProperty(value = "年龄",notes = "age>0")
    @TableField(value = "age")
    private Integer age;

    @ApiModelProperty(value = "邮箱")
    @TableField(value = "email")
    private String email;

    @JSONField(serializeUsing = ToStringSerializer.class)//log转换成string精度丢失问题
    @ApiModelProperty(value = "上级id",notes = "无上级则为0")
    @TableField(value = "manager_id")
    private Long managerId;

    @ApiModelProperty(value = "乐观锁",notes = "default 1")
    @TableField(value = "version")
    @Version        //乐观锁
    private Integer version;


    @ApiModelProperty(value = "逻辑删除")
    @TableField(value = "logic_delete",select = false)
    @TableLogic    //逻辑删除
    private Integer logicDelete;

    @ApiModelProperty(value = "创建时间" ,notes = "由数据库自动管理时间的更新")
    @TableField(value = "create_time")
    private LocalDateTime createTime;

    @ApiModelProperty(value = "更新时间" ,notes = "由数据库自动管理时间的更新")
    @TableField(value = "update_time")
    private LocalDateTime updateTime;


}
